<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"          
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      >
    <h:head>
        <f:metadata>
            <f:viewParam name="drugID" value="#{drugBean.drugID}"/>
            <f:event type="preRenderView" listener="#{drugBean.getDrugDetail}"/>
        </f:metadata>
    </h:head>
    <h:body>
        <ui:composition template="template/masterlayout.xhtml">
            <ui:define name="pagetitle">
                Edit Drug #{drugBean.drugName}
            </ui:define>
            <ui:define name="breadcrumb">
                <h:link value="Dashboard" outcome="index"/> &raquo; <h:link value="Drugs management" outcome="drugs"/> &raquo; <h:outputText value="Edit : #{drugBean.drugName}"/>
            </ui:define>
            <ui:define name="content">
                <h:form styleClass="jNice">
                    <fieldset>
                        <p>
                            <h:outputLabel for="drugName">Drug Name:</h:outputLabel>                            
                            <h:inputText id="drugName" value="#{drugBean.drugName}" required="true"
                                         requiredMessage="#{msgs.Drug_NameRequire}" validatorMessage="#{msgs.Drug_NameLeght}"
                                         >
                                <f:validateLength minimum="3" maximum="30"/>
                            </h:inputText>
                            <h:message for="drugName" styleClass="error"/>
                        </p>
                        <p>
                            <h:outputLabel for="drugPrice">Drug Price:</h:outputLabel>                            
                            <h:inputText id="drugPrice" value="#{drugBean.drugPrice}" converterMessage="${msgs.Drug_DrugPrice}">
                                <f:convertNumber/>
                            </h:inputText>  
                            <h:message for="drugPrice" styleClass="error"/>
                        </p>    
                        <p>
                            <h:outputLabel for="drugDescription">Drug Description:</h:outputLabel>
                            <h:inputTextarea id="drugDescription" value="#{drugBean.drugDescription}"/>
                        </p>     
                        <p>
                            <h:inputHidden value="#{drugBean.drugID}" id="drugId" />
                            <h:commandButton value="Update" action="#{drugBean.editDrug()}"/>
                        </p>
                    </fieldset>
                </h:form>
            </ui:define>
        </ui:composition>     
    </h:body>
</html>

